cmake_minimum_required (VERSION 2.6)
project (GL_workspace)

#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_CXX_FLAGS "-g -Wall")

find_package(GLUT REQUIRED)
find_package(OpenGL REQUIRED)
find_package(OpenCV REQUIRED)

find_package(PCL 1.3 REQUIRED COMPONENTS common io)

# Compile external dependencies
add_subdirectory(external)

include_directories(
  ${PCL_INCLUDE_DIRS}
  /usr/local/include/assimp/
  external/glfw-2.7.6/include/
  external/glm-0.9.4.0/
  external/glew-1.9.0/include/
  .)

link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

set(ALL_LIBS
  ${OPENGL_LIBRARY}
  ${GLUT_LIBRARY}
  ${OpenCV_LIBS}
  assimp
  GLFW_276
  GLEW_190)

add_definitions(
  -DTW_STATIC
  -DTW_NO_LIB_PRAGMA
  -DTW_NO_DIRECT3D
  -DGLEW_STATIC
  -D_CRT_SECURE_NO_WARNINGS)

# Executables
add_executable(main src/main.cpp
  src/camera.cpp
  src/camera.hpp
  src/buffer_util.hpp
  src/buffer_util.cpp
  src/mesh.hpp
  src/mesh.cpp
  common/shader.cpp
  common/shader.hpp
  common/texture.cpp
  common/texture.hpp
  common/objloader.cpp
  common/objloader.hpp
)

target_link_libraries(main ${ALL_LIBS})

add_executable(pcd2ply src/pcd2ply.cpp)
target_link_libraries(pcd2ply ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})

add_executable(testMesh src/test_mesh.cpp)
target_link_libraries(testMesh assimp)